<?php
namespace Modules\AuthAdmin\Services;
class QueryService  
{
	/**
	 * @name  查询条件
	 * @param model 模型
	 * @param params 所有参数
	 * @return 返回模型
	 */
	function query_condition($model,$params,$key="username"){
		if (!empty($params['created_at'])){
			$model = $model->whereBetween('created_at',explode('|',$params['created_at']));
		}
		if (!empty($params['updated_at'])){
			$model = $model->whereBetween('updated_at',explode('|',$params['updated_at']));
		}
		if (!empty($params['key'])){
			$model = $model->where($key,'like','%' . $params['key'] . '%');	
		}                  
		if (isset($params['status']) && $params['status'] != ''){
			$model = $model->where('status',$params['status']);
		}
		return $model;
	}
}
